# backend/Dockerfile
FROM python:3.12 AS backend

# 设置工作目录
WORKDIR /app

# 安装系统依赖
# 复制依赖文件并设置阿里云的 pip 源
COPY requirements.txt ./
RUN mkdir -p /etc && \
    echo "[global]" > /etc/pip.conf && \
    echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /etc/pip.conf && \
    echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /etc/pip.conf && \
    pip install --upgrade pip && \
    pip install --no-cache-dir --default-timeout=100 -r requirements.txt


# 复制项目文件
COPY . .


RUN python manage.py collectstatic --noinput


# 暴露端口
EXPOSE 8000

# 启动命令
CMD ["uwsgi", "--ini", "uwsgi.ini"]
